package org.birrap.entities;

import java.io.Serializable;
import java.util.Collection;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.Id;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.validation.constraints.NotNull;
import javax.validation.constraints.Size;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;


@Entity
@Table(name = "ROLES_T")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "RolesT.findAll", query = "SELECT r FROM RolesT r"),
    @NamedQuery(name = "RolesT.findByIdRol", query = "SELECT r FROM RolesT r WHERE r.idRol = :idRol"),
    @NamedQuery(name = "RolesT.findByDescripcion", query = "SELECT r FROM RolesT r WHERE r.descripcion = :descripcion")})
public class RolesT implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 20)
    @Column(name = "ID_ROL")
    private String idRol;
    @Basic(optional = false)
    @NotNull
    @Size(min = 1, max = 150)
    @Column(name = "DESCRIPCION")
    private String descripcion;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "idRol")
    private Collection<UsuariosT> usuariosTCollection;

    public RolesT() {
    }

    public RolesT(String idRol) {
        this.idRol = idRol;
    }

    public RolesT(String idRol, String descripcion) {
        this.idRol = idRol;
        this.descripcion = descripcion;
    }

    public String getIdRol() {
        return idRol;
    }

    public void setIdRol(String idRol) {
        this.idRol = idRol;
    }

    public String getDescripcion() {
        return descripcion;
    }

    public void setDescripcion(String descripcion) {
        this.descripcion = descripcion;
    }

    @XmlTransient
    public Collection<UsuariosT> getUsuariosTCollection() {
        return usuariosTCollection;
    }

    public void setUsuariosTCollection(Collection<UsuariosT> usuariosTCollection) {
        this.usuariosTCollection = usuariosTCollection;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (idRol != null ? idRol.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof RolesT)) {
            return false;
        }
        RolesT other = (RolesT) object;
        if ((this.idRol == null && other.idRol != null) || (this.idRol != null && !this.idRol.equals(other.idRol))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "org.birrap.ejb.RolesT[ idRol=" + idRol + " ]";
    }
    
}
